import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
  ],
  base:'/shopAdmin/',
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server:{ //服务器配置
    port:5173,  //端口
   proxy:{  //配置代理，解决跨域
    '/api':{  //工厂的接口以/api开头
      target:'http:localhost:5188', //被代理服务
      changeOrigin:true,  //改变源
      rewrite:(path)=>{   //映射规则
        return path.replace(/^\/api/,'')   //将http://localhost:5173/api/login   ->   http://localhost:5188/login
      }
    }
   }
  }
})
